/**
CParty: Class holding the party information.
**/
#pragma once

#ifndef _CPARTY_H_
#define _CPARTY_H_

#include <windows.h>
#include "structs.h"
#include <vector>
#include "CChar.h"
#include "CBaseEntity.h"
#include "CAlliance.h"

class CAlliance;
class CParty;
class CChar;

class CParty {
public:
	CParty(void);
	~CParty(void);

	//If the party is in an alliance, this will be the parties index number (+1) in the alliance
	unsigned int inAlliance;

	//Starts the disbanding process; checks if there is an alliance to dissolve, valid leader.. etc
	int startDisband(CChar * member);

	//Assigns a party member a role, such as leader, quarter master, lvlsync
	int assignPartyRole(CChar * assigner, CChar * assignee, int role);

	//Kicks everyone out of the party
	int disbandParty(void);

	//Drops the treasure pools for everyone in the party
	void dropTreasurePool(void);

	//Rebuilds the treasure pool for this party
	void rebuildTreasurePool(void);

	//Returns the number of members in a party
	unsigned int memberCount(void);
	
	//Adds the character to the party list (no error checking)
	int addMember(CChar * member);
	
	//Removes the person from the party (no error checking)
	int removeMember(CChar * member);

	//Re-sends everyones stats (hp/mp/tp) in the party/alliance to the schar member
	//	if bRemove is true the function will remove everyone from the party for the player that called the function
	int reloadParty(CChar * schar,bool bRemove);

	//Returns the current leader of the party. It shouldn't but could return a NULL value
	CChar * getLeader(void);

	//Returns the level sync target for the party (WILL RETURN NULL IF NOT SET) 
	CChar * getLvlSync(void);

	//Returns the quarter master for the party (WILL RETURN NULL IF NOT SET)
	CChar * getQM(void);

	//Returns the alliance the party belongs to (if it does) WILL RETURN NULL IF PARTY DOES NOT BELONG TO AN ALLIANCE
	CAlliance * getAlliance(void);

	//Sets the party leader (CANNOT BE NULL)
	int setLeader(CChar * leader);

	//Sets the level sync target (NULL MEANS NOT USED / REMOVED)
	int setLvlSync(CChar * lvlSync);

	//Sets the Quarter Master (NULL MEANS NOT USED / REMOVED)
	int setQM(CChar * qm);

	//Sets the Alliance the party belongs to (NULL MEANS NOT USED / REMOVED)
	int setAlliance(CAlliance * alliance);

	//List of party members
	std::vector<CChar*> members;

	bool lockPartyList(void);
	bool unlockPartyList(void);

private:
	CAlliance * alliance;			//if in an alliance, reference it for ease of access
	CChar * pLeader;				//Party leader
	CChar * lvlSync;				//LevelSync target
	CChar * qm;						//Quarter Master
	CSemaphore* partyListSemaphore; //Locks and unlocks the party list

};

#endif

